$(function() {
    if (getQueryString("key") != "") {
        var a = getQueryString("key");
        var e = getQueryString("username");
        addCookie("key", a);
        addCookie("username", e)
    } else {
        var a = getCookie("key")
    }
    if (a) {
        $.ajax({
            type: "post",
            url: ApiUrl + "/index.php?act=member_index",
            data: {
                key: a
            },
            dataType: "json",
            success: function(a) {
                console.log(a);
                checkLogin(a.login);
                var e = '<a class="member-info" href="/wap/tmpl/member/profile.php">' + '<div class="user-avatar"> <img src="' + a.datas.member_info.avator + '"/> </div>' + '<div class="user-name"> <span>' + a.datas.member_info.user_name + "</span> </div>" + "</a>" ;
                $(".member-top").html(e);
                var e = '<li><a href="order_list.html?data-state=state_new">' + (a.datas.member_info.order_nopay_count > 0 ? "<em>"+a.datas.member_info.order_nopay_count+"</em>": "") + '<i class="cc-01"></i><p>待付款</p></a></li>' + '<li><a href="order_list.html?data-state=state_ready">' + (a.datas.member_info.order_paycount_count > 0 ? "<em>"+a.datas.member_info.order_paycount_count+"</em>": "") + '<i class="cc-01-1"></i><p>待发货</p></a></li>' + '<li><a href="order_list.html?data-state=state_send">' + (a.datas.member_info.order_noreceipt_count > 0 ? "<em>"+a.datas.member_info.order_noreceipt_count+"</em>": "") + '<i class="cc-02"></i><p>待收货</p></a></li>' +  '<li><a href="order_list.html?data-state=state_noeval">' + (a.datas.member_info.order_noeval_count > 0 ? "<em>"+a.datas.member_info.order_noeval_count+"</em>": "") + '<i class="cc-04"></i><p>待评价</p></a></li>' + '<li><a href="member_refund.php">' + (a.datas.member_info.return > 0 ? "<em>"+a.datas.member_info.return+"</em>": "") + '<i class="cc-05"></i><p>退款/退货</p></a></li>';
                $("#order_ul").html(e);
                var e = '<li><a href="predepositlog_list.php"><i class="cc-06"></i><p>账户余额</p></a></li>' + '<li><a href="voucher_list.php"><i class="cc-08"></i><p>代金券</p></a></li>' + '<li><a href="pointslog_list.php"><i class="cc-10"></i><p>积分</p></a></li>';
                $("#asset_ul").html(e);
                return false
            }
        })
    } else {
        var i = '<div class="member-info">' + '<a href="login.html" class="default-avatar" style="display:block;"></a>' + '<a href="login.html" class="to-login">点击登录</a>' + "</div>" + '<div class="member-collect"><span><a href="login.html"><i class="favorite-goods"></i>' + "<p>商品收藏</p>" + '</a> </span><span><a href="login.html"><i class="favorite-store"></i>' + "<p>店铺收藏</p>" + '</a> </span><span><a href="login.html"><i class="goods-browse"></i>' + "<p>我的足迹</p>" + "</a> </span></div>";
        $(".member-top").html(i);
        var i = '<li><a href="login.html"><i class="cc-01"></i><p>待付款</p></a></li>' + '<li><a href="login.html"><i class="cc-02"></i><p>待收货</p></a></li>' +  '<li><a href="login.html"><i class="cc-04"></i><p>待评价</p></a></li>' + '<li><a href="login.html"><i class="cc-05"></i><p>退款/退货</p></a></li>';
        $("#order_ul").html(i);
        return false
    }
    $.scrollTransparent()
});